<?
CheckAdmin($admin_user, $admin_pwd);
include ("editor.php");
empty($_POST['ENABLE_COMMENT'])?$ENABLE_COMMENT="":$ENABLE_COMMENT=$_POST['ENABLE_COMMENT'];
?>

	<TABLE cellSpacing=0 cellPadding=0 width=820 border=0>
      <TBODY>
        <TR>
          <TD width="10" vAlign=top><IMG src="images/fader.gif" border=0></TD>
          <TD width="810" vAlign=top><IMG src="images/topfader.gif" border=0><BR>
		  <!-- Admin -->
		  &nbsp;&nbsp;<IMG SRC="images/menu/textmenu_admin.gif" BORDER="0"><BR>
				<TABLE width="800" align=center cellSpacing=0 cellPadding=5 border=0>
				<TR>
					<TD height="1" class="dotline"></TD>
				</TR>
				<TR>
					<TD>
					<BR><B><IMG SRC="images/icon/plus.gif" BORDER="0" ALIGN="absmiddle"> <A HREF="?name=admin&file=main"><?=_ADMIN_GOBACK;?></A> &nbsp;&nbsp;<IMG SRC="images/icon/arrow_wap.gif" BORDER="0" ALIGN="absmiddle">&nbsp;&nbsp; <?=_ADMIN_NEW_MENU_TITLE;?></B>
					<BR><BR>
					<A HREF="?name=admin&file=news"><IMG SRC="images/admin/open.gif"  BORDER="0" align="absmiddle"> <?=_ADMIN_NEW_MENU_TITLE_ALL;?></A> &nbsp;&nbsp;&nbsp;<A HREF="?name=admin&file=news&op=news_add"><IMG SRC="images/admin/book.gif"  BORDER="0" align="absmiddle"> <?=_ADMIN_NEW_MENU_TITLE_ADD_NEW;?></A> &nbsp;&nbsp;&nbsp;<A HREF="?name=admin&file=news_category"><IMG SRC="images/admin/folders.gif"  BORDER="0" align="absmiddle"><?=_ADMIN_MENU_DTAIL_CAT;?></A> &nbsp;&nbsp;&nbsp;<A HREF="?name=admin&file=news_category&op=newscat_add"><IMG SRC="images/admin/opendir.gif"  BORDER="0" align="absmiddle"><?=_ADMIN_MENU_ADD_CAT;?></A><BR><BR>
<?
//////////////////////////////////////////// แสดงรายการข่าวสาร / ประชาสัมพันธ์ 
if($op == ""){
	$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
	$limit = 20 ;
	$SUMPAGE = $db->num_rows(TB_NEWS,"id_news","");

	if (empty($page)){
		$page=1;
	}
	$rt = $SUMPAGE%$limit ;
	$totalpage = ($rt!=0) ? floor($SUMPAGE/$limit)+1 : floor($SUMPAGE/$limit); 
	$goto = ($page-1)*$limit ;
?>
 <form action="?name=admin&file=news&op=news_del&action=multidel" name="myform" method="post">
 <table width="100%" cellspacing="0" cellpadding="0" class="grids">
  <tr class="odd">
   <td width="44"><CENTER><B>Option</B></CENTER></td>
   <td><CENTER><B><?=_ADMIN_TABLE_TITLE_TOPIC;?></B></CENTER></td>
   <td width="100"><CENTER><B><?=_ADMIN_TABLE_TITLE_POSTED;?></B></CENTER></td>
   <td width="40"><CENTER><B><?=_ADMIN_TABLE_TITLE_CAT;?></B></CENTER></td>
   <td width="40"><CENTER><B>Check</B></CENTER></td>
   <td width="40"><CENTER><B>Ran</B></CENTER></td>
   <td width="40"><CENTER><B>LinkURL</B></CENTER></td>
  </tr>  
<?
$res['news'] = $db->select_query("SELECT * FROM ".TB_NEWS." ORDER BY id_news DESC LIMIT $goto, $limit ");
$count=0;
while($arr['news'] = $db->fetch($res['news'])){
	$res['category'] = $db->select_query("SELECT * FROM ".TB_NEWS_CAT." WHERE id='".$arr['news']['category']."' ");
	$arr['category'] = $db->fetch($res['category']);
	//Comment Icon
	if($arr['news']['enable_comment']){
		$CommentIcon = " <IMG SRC=\"images/icon/comments-icon.jpg\" WIDTH=\"16\" HEIGHT=\"16\" BORDER=\"0\" ALIGN=\"absmiddle\" alt=\""._ADMIN_LINK_ALLOW_COMMENT."\">";
	}else{
		$CommentIcon = "";
	}
	if($arr['news']['pic']==1){
		$PicIcon = " <A HREF=icon/news_".$arr['news']['date'].".jpg class=\"highslide\" onclick=\"return hs.expand(this)\"><IMG SRC=\"images/preview.gif\" WIDTH=\"16\" HEIGHT=\"16\" BORDER=\"0\" ALIGN=\"absmiddle\" alt=\""._ADMIN_LINK_PICTURE."\"></a>";
	}else{
		$PicIcon = "";
	}
	if($arr['news']['pic_news'] !=''){
		$AttIcon = " <a href=attach/news_".$arr['news']['pic_news']."><IMG SRC=\"images/attach.gif\" WIDTH=\"8\" HEIGHT=\"13\" BORDER=\"0\" ALIGN=\"absmiddle\" alt=\""._ADMIN_LINK_FILE_ATT."\"></a>";
	}else{
		$AttIcon = "";
	}

if($count%2==0) { //ส่วนของการ สลับสี 
$ColorFill = ' onmouseover="this.style.backgroundColor=\'#FFF0DF\'" onmouseout="this.style.backgroundColor=\'#ffffff\'"  ';
} else {
$ColorFill = 'class="odd"';
}
$res['ran'] = $db->select_query("SELECT * FROM ".TB_RANDOM." where rm_news='".$arr['news']['id_news']."' ");
$arr['ran'] = $db->fetch($res['ran']);
?>
    <tr <?php echo $ColorFill; ?> >
     <td width="44">
      <a href="?name=admin&file=news&op=news_edit&id_news=<? echo $arr['news']['id_news'];?>"><img src="images/admin/edit.gif" border="0" alt="<?=_ADMIN_BUTTON_EDIT;?>" ></a> 
      <a href="javascript:Confirm('?name=admin&file=news&op=news_del&id_news=<? echo $arr['news']['id_news'];?>&pic=<? echo $arr['news']['pic'];?>&prefix=<? echo $arr['news']['date'];?>','<?=_ADMIN_BUTTON_DEL_MESSAGE;?>');"><img src="images/admin/trash.gif"  border="0" alt="<?=_ADMIN_BUTTON_DEL;?>" ></a>
     </td> 
     <td><A HREF="?name=news&file=readnews&id_news=<?echo $arr['news']['id_news'];?>" target="_blank"><?echo $arr['news']['headnews'];?></A><?=$CommentIcon;?><?=$PicIcon;?><?=$AttIcon;?><?=NewsIcon(TIMESTAMP, $arr['news']['date'], "images/icon_new.gif");?></td>
     <td ><CENTER><?echo ThaiTimeConvert($arr['news']['date'],'','');?></CENTER></td>
     <td align="center">
	 <?if($arr['category']['category_name']){ //หากมีหมวดแสดงรูป ?>
	 <A HREF="#"><IMG SRC="images/admin/folders.gif"  BORDER="0" align="absmiddle" alt="<?echo $arr['category']['category_name'];?>" onMouseOver="MM_displayStatusMsg('<?echo $arr['category']['category_name'];?>');return document.MM_returnValue"></A>
	 <? } ?>
	 </td>
     <td valign="top" align="center" width="40"><input type="checkbox" name="list[]" value="<? echo $arr['news']['id_news'];?>"></td>
     <td valign="top" align="center" width="40"><?if ($arr['news']['ran'] !=0){if ($arr['ran']['status']==0){?><a href="?name=admin&file=news&op=news_ran&id=<? echo $arr['ran']['id'];?>&fix=up"><img src="images/publish_x.png" border="0" alt="<?=_ADMIN_STATUS_OPEN;?>" ></a><?}else {?><a href="?name=admin&file=news&op=news_ran&id=<? echo $arr['news']['id'];?>&fix=down"><img src="images/tick.png" border="0" alt="<?=_ADMIN_STATUS_CLOSE;?>" ></a><?} }else{ echo "<font color=#CC0000><b>NO</b></font>"; }?></td>
     <td valign="top" align="center" width="40"><?if ($arr['news']['linkurl'] !=''){ ?><img src="images/tick.png" border="0" alt="<?=_ADMIN_STATUS_OPEN;?>" ></a><?} else{ echo "<font color=#CC0000><b>NO</b></font>"; }?></td>     
    </tr>

<?
	$count++;
 } 
?>
 </table>
 <div align="right">
 <input type="button" name="CheckAll" value="Check All" onclick="checkAll(document.myform)" >
 <input type="button" name="UnCheckAll" value="Uncheck All" onclick="uncheckAll(document.myform)" >
 <input type="hidden" name="ACTION" value="news_del">
 <input type="submit" value="Delete" onclick="return delConfirm(document.myform)">
 </div>
 </form><BR><BR>
<?
	SplitPage($page,$totalpage,"?name=admin&file=news");
	echo $ShowSumPages ;
	echo "<BR>";
	echo $ShowPages ;
}
else if($op == "news_add" AND $action == "add"){
        $db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
        $gen_id['gen'] = $db->select_query("SELECT id_news FROM ".TB_NEWS." order by id_news desc limit 1 ");
        $gen_id['gen'] = $db->fetch($gen_id['gen']);
        $gen_id_news   = $gen_id['gen']['id_news']+1;
        $db->closedb ();        
//        echo "gen_id_news".$gen_id_news;       
	//////////////////////////////////////////// กรณีเพิ่ม Database
	if(CheckLevel($admin_user,$op)){

		$FILE = $_FILES['FILE'];
		$FILESS=$_FILES['FILESS'];
		if (!$_POST['CATEGORY'] OR !$_POST['HEADNEWS'] OR !$_POST['HEADLINE'] OR !$_POST['DETAIL'] ){
			echo "<script language='javascript'>" ;
			echo "alert('"._JAVA_DATA_NULL."')" ;
			echo "</script>" ;
			echo "<script language='javascript'>javascript:history.back()</script>";
			exit();
		}
$FILER = $_FILES['FILER'];
if ($FILER['name'] !=''){
	$size = getimagesize($FILER['tmp_name']);
	$widths = $size[0];
	$heights = $size[1];
	if ($widths*$heights > _IRAN_W*_IRAN_H) {
		if (($FILER['type']=='image/jpg') || ($FILER['type']=='image/jpeg') || ($FILER['type']=='image/pjpeg')){
			$upload=copy($FILER['tmp_name'], "icon/ranb_".$FILER['name']."");
//			@copy ($FILER['tmp_name'] , "icon/ran_".TIMESTAMP.".jpg" );
			$original_image = "icon/ranb_".$FILER['name']."" ;
			$desired_width = _IRAN_W ;
			$desired_height = _IRAN_H ;
			$image = new hft_image($original_image);
			$image->resize($desired_width, $desired_height, '0');
			$image->output_resized("icon/ran_".$FILER['name']."", "JPG");
		} if (($FILER['type']=='image/gif')){
			$upload=copy($FILER['tmp_name'], "icon/ranb_".$FILER['name']."");
//			@copy ($FILER['tmp_name'] , "icon/ran_".TIMESTAMP.".jpg" );
			$original_image = "icon/ranb_".$FILER['name']."" ;
			$desired_width = _IRAN_W ;
			$desired_height = _IRAN_H ;
			$image = new hft_image($original_image);
			$image->resize($desired_width, $desired_height, '0');
			$image->output_resized("icon/ran_".$FILER['name']."", "GIF");
		}if (($FILER['type']=='image/x-png')){
			$upload=copy($FILER['tmp_name'], "icon/ranb_".$FILER['name']."");
//			@copy ($FILER['tmp_name'] , "icon/ran_".TIMESTAMP.".jpg" );
			$original_image = "icon/ranb_".$FILER['name']."" ;
			$desired_width = _IRAN_W ;
			$desired_height = _IRAN_H ;
			$image = new hft_image($original_image);
			$image->resize($desired_width, $desired_height, '0');
			$image->output_resized("icon/ran_".$FILER['name']."", "PNG");
		}
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$res['ran'] = $db->select_query("SELECT id FROM ".TB_NEWS." order by update_date desc limit 1 ");
		$rows['ran'] = $db->fetch($res['ran']);
		$newID=$rows['ran']['id']+1;
		$db->add_db(TB_RANDOM,array(
			"rm_news"=>"".$newID."",
			"rm_image"=>"ran_".$FILER['name']."",
			"rm_topic"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"rm_detail"=>"".$_POST['HEADLINE']."",
			"rm_link"=>"".WEB_URL."/?name=news&file=readnews&id_news=".$newID."",
			"width"=>"".$widths."",
			"height"=>"".$heights."",
			"type"=>"".$FILER['type']."",
			"size"=>"".$FILER['size']."",
			"status"=>"1"
		));
		$db->closedb ();
	} else {
		$upload=copy($FILER['tmp_name'], "icon/ran_".$FILER['name']."");
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$res['ran'] = $db->select_query("SELECT id FROM ".TB_NEWS." order by update_date desc limit 1 ");
		$rows['ran'] = $db->fetch($res['ran']);
		$newID=$rows['ran']['id']+1;
		$db->add_db(TB_RANDOM,array(
			"rm_news"=>"".$newID."",
			"rm_image"=>"ran_".$FILER['name']."",
			"rm_topic"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"rm_detail"=>"".$_POST['HEADLINE']."",
			"rm_link"=>"".WEB_URL."/?name=news&file=readnews&id=".$newID."",
			"width"=>"".$widths."",
			"height"=>"".$heights."",
			"type"=>"".$FILER['type']."",
			"size"=>"".$FILER['size']."",
			"status"=>"1"
		));
		$db->closedb ();
	}
$ran='1';
} else{
$ran='0';
}

if ($FILE['name'] !='') {
		require("includes/class.resizepic.php");
		if (($FILE['type']!="image/jpg") AND ($FILE['type']!="image/jpeg") AND ($FILE['type']!="image/pjpeg")){
			echo "<script language='javascript'>" ;
			echo "alert('"._JAVA_IMG_ACC."')" ;
			echo "</script>" ;
			echo "<script language='javascript'>javascript:history.back()</script>";
			exit();
		}else{
			@copy ($FILE['tmp_name'] , "icon/news_".TIMESTAMP.".jpg" );
			$original_image = "icon/news_".TIMESTAMP.".jpg" ;
			$desired_width = _INEWS_W ;
			$desired_height = _INEWS_H ;
			$image = new hft_image($original_image);
			$image->resize($desired_width, $desired_height, '0');
			$image->output_resized("icon/news_".TIMESTAMP.".jpg", "JPG");
		}
	$pic='1';
} else {
	$pic='0';
}

if ($FILESS['name'] !='') {
		//ทำการเพิ่มข้อมูลลงดาต้าเบส
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$db->add_db(TB_NEWS,array(
                        "id_news"=>"".$gen_id_news."",
                        "id_temple"=>""._NEWS_ID_TEMPLE."",
			"category"=>"".$_POST['CATEGORY']."",
			"headnews"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"headline"=>"".$_POST['HEADLINE']."",
			"detail"=>"".$_POST['DETAIL']."",
			"posted"=>"".$admin_user."",
			"date"=>"".TIMESTAMP."",
			"update_date"=>"".TIMESTAMP."",
			"pic_news"=>"".TIMESTAMP."_".$FILESS['name']."",
			"pic"=>"".$pic."",
			"enable_comment"=>"".$ENABLE_COMMENT."",
			"ran"=>"".$ran."",
			"linkurl"=>"".$_POST['LINKURL'].""
		));
		$db->closedb ();
	@copy ($FILESS['tmp_name'] , "attach/news_".TIMESTAMP."_".$FILESS['name']."");
} else {

		//ทำการเพิ่มข้อมูลลงดาต้าเบส
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$db->add_db(TB_NEWS,array(
                        "id_news"=>"".$gen_id_news."",
                        "id_temple"=>""._NEWS_ID_TEMPLE."",                    
			"category"=>"".$_POST['CATEGORY']."",
			"headnews"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"headline"=>"".$_POST['HEADLINE']."",
			"detail"=>"".$_POST['DETAIL']."",
			"posted"=>"".$admin_user."",
			"date"=>"".TIMESTAMP."",
			"update_date"=>"".TIMESTAMP."",
                        "pic_news"=>"",                    
			"pic"=>"".$pic."",
			"enable_comment"=>"".$ENABLE_COMMENT."",
			"ran"=>"".$ran."",
			"linkurl"=>"".$_POST['LINKURL'].""
		));
		$db->closedb ();
}

$data ='<?xml version="1.0" encoding="'.$iso.'"?>'."\n";
$data .='<rss version="2.0">'."\n";
$data .='<channel>'."\n";

$data .='<title>'.WEB_TITILE.'</title>'."\n";
$data .='<description>'._ADMIN_NEW_MENU_TITLE.'</description>'."\n";
$data .='<link>'.WEB_URL.'</link>'."\n";
$data .='<lastBuildDate>'.date("D, d M Y H:i:s").'</lastBuildDate>'."\n";

$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
$listof= $db->select_query("SELECT * FROM ".TB_NEWS." where category='2' ORDER BY id_news desc limit 10");

while($result = $db->fetch($listof)) {
$timesdate=ThaiTimeConvert($result['date'],"1","");
	$res['category'] = $db->select_query("SELECT * FROM ".TB_NEWS_CAT." WHERE id='".$result['category']."' ");
	$arr['category'] = $db->fetch($res['category']);

if($result['pic']==1){
$pics=''.WEB_URL.'/icon/news_'.$result['date'].'.jpg';
}else {
$pics=''.WEB_URL.'/images/icon/'.$arr['category']['icon'].'';
}
$data .='<item>'."\n"; 
$data .='<title>'.$result['headnews'].'</title>'."\n"; 
$data .='<link>'.WEB_URL.'/?name=news&amp;file=readnews&amp;id_news='.$result['id_news'].'</link>'."\n"; 
$data .='<pic>'.WEB_URL.'/'.$pics.'</pic>'."\n";
$data .='<description>'.$result['headline'].'</description>'."\n";
$data .='<pubDate>'.$result['date'].'</pubDate>'."\n";
$data .='</item>'."\n"; 
}

$data .='</channel>'."\n";
$data .='</rss>'."\n";

$f = fopen( 'modules/rss/news.xml' , 'w' ); // 2 อ่านหมายเหตุของบรรทัดนี้ด้านล่าง
fputs( $f , $data );
fclose( $f );

		$ProcessOutput = "<BR><BR>";
		$ProcessOutput .= "<CENTER><A HREF=\"?name=admin&file=main\"><IMG SRC=\"images/icon/login-welcome.gif\" BORDER=\"0\"></A><BR><BR>";
		$ProcessOutput .= "<FONT COLOR=\"#336600\"><B>"._ADMIN_NEW_MESSAGE_ADD."</B></FONT><BR><BR>";
		$ProcessOutput .= "<A HREF=\"?name=admin&file=news\"><B>"._ADMIN_NEW_MESSAGE_GOBACK."</B></A>";
		$ProcessOutput .= "</CENTER>";
		$ProcessOutput .= "<meta http-equiv='refresh' content='1; url=?name=admin&file=news'>";
		$ProcessOutput .= "<BR><BR>";
	}else{
		//กรณีไม่ผ่าน
		$ProcessOutput = $PermissionFalse ;
	}
	echo $ProcessOutput ;
}
else if($op == "news_add"){
	//////////////////////////////////////////// กรณีเพิ่ม Form
	if(CheckLevel($admin_user,$op)){
         
?>
<FORM NAME="myform" METHOD=POST ACTION="?name=admin&file=news&op=news_add&action=add" enctype="multipart/form-data">
<B><?=_ADMIN_FORM_TOPIC;?> :</B><BR>
<INPUT TYPE="text" NAME="HEADNEWS" size="80">
<BR><BR>
<B><?=_ADMIN_FORM_CAT;?> :</B><BR>
<SELECT NAME="CATEGORY">
<?
$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
$res['category'] = $db->select_query("SELECT * FROM ".TB_NEWS_CAT." ORDER BY sort ");
while ($arr['category'] = $db->fetch($res['category'])){
	   echo "<option value=\"".$arr['category']['id']."\"";
	   echo ">".$arr['category']['category_name']."</option>";
}
$db->closedb ();
?>
</SELECT>
<BR><BR>
<B><?=_ADMIN_FORM_ICON;?> : </B><BR>
<IMG name="view01" SRC="images/news_blank.gif" <?echo " WIDTH=\""._INEWS_W."\" HEIGHT=\""._INEWS_H."\" ";?> BORDER="0" ><BR>
<input type="file" name="FILE" onpropertychange="view01.src=FILE.value;" style="width:250;"><BR>
<?=_ADMIN_FORM_ICON_WIDTH;?> <?echo _INEWS_W." x "._INEWS_H ;?> <?=_ADMIN_FORM_ICON_WIDTH1;?>
<BR><BR>
<B><?=_ADMIN_FORM_HEADLINE;?> :</B><BR>
<textarea cols="100" rows="10"  name="HEADLINE" ></textarea>
<script type="text/javascript">CKEDITOR.replace ( 'editor1',{toolbar: 'AdminBasic'});</script>
<BR><BR>

<B><?=_ADMIN_FORM_DETAIL;?> :</B><BR>

<textarea cols="100" id="DETAIL" rows="50" class="ckeditor"  name="DETAIL" ></textarea>

<BR>
<B><?=_ADMIN_FORM_LINK_URL;?> : </B><BR>
<INPUT TYPE="text" NAME="LINKURL" size="100">
<br>
<B><?=_ADMIN_FORM_FILE_ATT;?> : </B><BR>
<input type="file" name="FILESS" onpropertychange="view01.src=FILESS.value;" style="width:250;">
<br>
<B><?=_ADMIN_NEW_ROTATOR_PIC;?> : </B><BR>
<input type="file" name="FILER" onpropertychange="view01.src=FILER.value;" style="width:250;"><BR>
<?=_ADMIN_FORM_ICON_WIDTH;?> <?echo _IRAN_W." x "._IRAN_H ;?> <?=_ADMIN_FORM_CAT_ICON_WIDTH;?>
<br>

<INPUT TYPE="checkbox" NAME="ENABLE_COMMENT" VALUE="1"> <?=_ADMIN_FORM_ALLOW_COMMENT;?>
<BR>
<input type="submit" value="<?=_ADMIN_NEW_BUTTON_ADD;?>" name="submit"> <input type="reset" value="<?=_ADMIN_BUTTON_CLEAR;?>" name="reset">
</FORM>
<BR><BR>
<?
	}else{
		//กรณีไม่ผ่าน
		echo  $PermissionFalse ;
	}
}
else if($op == "news_edit" AND $action == "edit"){
	//////////////////////////////////////////// กรณีแก้ไข Database Edit
	if(CheckLevel($admin_user,$op)){
		//ดึงค่า
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$res['news'] = $db->select_query("SELECT * FROM ".TB_NEWS." WHERE id_news='".$_GET['id_news']."' ");
		$arr['news'] = $db->fetch($res['news']);
		$db->closedb ();

		$FILE = $_FILES['FILE'];
		$FILESS=$_FILES['FILESS'];
		if (!$_POST['CATEGORY'] OR !$_POST['HEADNEWS'] OR !$_POST['HEADLINE'] OR !$_POST['DETAIL']){
			echo "<script language='javascript'>" ;
			echo "alert('"._JAVA_DATA_NULL."')" ;
			echo "</script>" ;
			echo "<script language='javascript'>javascript:history.back()</script>";
			exit();
		}
$FILER = $_FILES['FILER'];
if ($FILER['name'] !=''){
	$size = getimagesize($FILER['tmp_name']);
	$widths = $size[0];
	$heights = $size[1];
	if ($widths*$heights > _IRAN_W*_IRAN_H) {
		if (($FILER['type']=='image/jpg') || ($FILER['type']=='image/jpeg') || ($FILER['type']=='image/pjpeg')){
			$upload=copy($FILER['tmp_name'], "icon/ranb_".$FILER['name']."");
//			@copy ($FILER['tmp_name'] , "icon/ran_".TIMESTAMP.".jpg" );
			$original_image = "icon/ranb_".$FILER['name']."" ;
			$desired_width = _IRAN_W ;
			$desired_height = _IRAN_H ;
			$image = new hft_image($original_image);
			$image->resize($desired_width, $desired_height, '0');
			$image->output_resized("icon/ran_".$FILER['name']."", "JPG");
		} if (($FILER['type']=='image/gif')){
			$upload=copy($FILER['tmp_name'], "icon/ranb_".$FILER['name']."");
//			@copy ($FILER['tmp_name'] , "icon/ran_".TIMESTAMP.".jpg" );
			$original_image = "icon/ranb_".$FILER['name']."" ;
			$desired_width = _IRAN_W ;
			$desired_height = _IRAN_H ;
			$image = new hft_image($original_image);
			$image->resize($desired_width, $desired_height, '0');
			$image->output_resized("icon/ran_".$FILER['name']."", "GIF");
		}if (($FILER['type']=='image/x-png')){
			$upload=copy($FILER['tmp_name'], "icon/ranb_".$FILER['name']."");
//			@copy ($FILER['tmp_name'] , "icon/ran_".TIMESTAMP.".jpg" );
			$original_image = "icon/ranb_".$FILER['name']."" ;
			$desired_width = _IRAN_W ;
			$desired_height = _IRAN_H ;
			$image = new hft_image($original_image);
			$image->resize($desired_width, $desired_height, '0');
			$image->output_resized("icon/ran_".$FILER['name']."", "PNG");
		}
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$res['ran'] = $db->select_query("SELECT * FROM ".TB_RANDOM." where rm_news='".$_GET['id_news']."' ");
		$rows['ran'] = $db->fetch($res['ran']);
		$newID=$rows['ran']['id'];
		if ($newID !=''){
		$db->update_db(TB_RANDOM,array(
			"rm_image"=>"ran_".$FILER['name']."",
			"rm_topic"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"rm_detail"=>"".$_POST['HEADLINE']."",
			"rm_link"=>"".WEB_URL."/?name=news&file=readnews&id_news=".$_GET['id_news']."",
			"width"=>"".$widths."",
			"height"=>"".$heights."",
			"type"=>"".$FILER['type']."",
			"size"=>"".$FILER['size']."",
			"status"=>"1"
		)," rm_news=".$_GET['id_news']."");
		$db->closedb ();
		} else {
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$db->add_db(TB_RANDOM,array(
			"rm_news"=>"".$_GET['id_news']."",
			"rm_image"=>"ran_".$FILER['name']."",
			"rm_topic"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"rm_detail"=>"".$_POST['HEADLINE']."",
			"rm_link"=>"".WEB_URL."/?name=news&file=readnews&id_news=".$_GET['id_news']."",
			"width"=>"".$widths."",
			"height"=>"".$heights."",
			"type"=>"".$FILER['type']."",
			"size"=>"".$FILER['size']."",
			"status"=>"1"
		));
		$db->closedb ();
		}
	} else {
		$upload=copy($FILER['tmp_name'], "icon/ran_".$FILER['name']."");
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$res['ran'] = $db->select_query("SELECT * FROM ".TB_RANDOM." where rm_news='".$_GET['id_news']."' ");
		$rows['ran'] = $db->fetch($res['ran']);
		$newID=$rows['ran']['id'];
		if ($newID !=''){
		$db->update_db(TB_RANDOM,array(
			"rm_image"=>"ran_".$FILER['name']."",
			"rm_topic"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"rm_detail"=>"".$_POST['HEADLINE']."",
			"rm_link"=>"".WEB_URL."/?name=news&file=readnews&id_news=".$_GET['id_news']."",
			"width"=>"".$widths."",
			"height"=>"".$heights."",
			"type"=>"".$FILER['type']."",
			"size"=>"".$FILER['size']."",
			"status"=>"1"
		)," rm_news=".$_GET['id']."");
		$db->closedb ();
		} else {
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$db->add_db(TB_RANDOM,array(
			"rm_news"=>"".$_GET['id_news']."",
			"rm_image"=>"ran_".$FILER['name']."",
			"rm_topic"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"rm_detail"=>"".$_POST['HEADLINE']."",
			"rm_link"=>"".WEB_URL."/?name=news&file=readnews&id_news=".$_GET['id_news']."",
			"width"=>"".$widths."",
			"height"=>"".$heights."",
			"type"=>"".$FILER['type']."",
			"size"=>"".$FILER['size']."",
			"status"=>"1"
		));
		$db->closedb ();
		}

	}
$ran='1';
} else{
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$res['ran'] = $db->select_query("SELECT id_news FROM ".TB_NEWS." where id_news='".$_GET['id_news']."' ");
		$rows['ran'] = $db->fetch($res['ran']);
		if ($rows['ran']['ran']==1){
		$ran='1';
		}else {
		$ran='0';
		}
}

if ($FILE['name'] !='') {
		require("includes/class.resizepic.php");
		if ((($FILE['type']!="image/jpg") AND ($FILE['type']!="image/jpeg") AND ($FILE['type']!="image/pjpeg")) AND $FILE['size']){
			echo "<script language='javascript'>" ;
			echo "alert('"._JAVA_IMG_ACC."')" ;
			echo "</script>" ;
			echo "<script language='javascript'>javascript:history.back()</script>";
			exit();
		}
			@copy ($FILE['tmp_name'] , "icon/news_".$arr['news']['date'].".jpg" );
			$original_image = "icon/news_".$arr['news']['date'].".jpg" ;
			$desired_width = _INEWS_W ;
			$desired_height = _INEWS_H ;
			$image = new hft_image($original_image);
			$image->resize($desired_width, $desired_height, '0');
			$image->output_resized("icon/news_".$arr['news']['date'].".jpg", "JPG");
	$pic='1';
} else {
	if($arr['news']['pic'] ==1){
	$pic='1';} else {
	$pic='0';
	}
}
if ($FILESS['name'] !='') {
		//ทำการเพิ่มข้อมูลลงดาต้าเบส
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$db->update_db(TB_NEWS,array(
			"category"=>"".$_POST['CATEGORY']."",
			"headnews"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"headline"=>"".$_POST['HEADLINE']."",
			"detail"=>"".$_POST['DETAIL']."",
			"posted"=>"".$admin_user."",
			"date"=>"".$arr['news']['date']."",
			"update_date"=>"".$arr['news']['date']."",
			"pic_news"=>"".$arr['news']['date']."_".$FILESS['name']."",
			"pic"=>"".$pic."",
			"enable_comment"=>"".$ENABLE_COMMENT."",
			"ran"=>"".$ran."",
                        "linkurl"=>"".$_POST['LINKURL'].""
		)," id_news=".$_GET['id_news']."");
		$db->closedb ();
	@copy ($FILESS['tmp_name'] , "attach/news_".$arr['news']['date']."_".$FILESS['name']."");
} else {

		//ทำการแก้ไขข้อมูลลงดาต้าเบส
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$db->update_db(TB_NEWS,array(
			"category"=>"".$_POST['CATEGORY']."",
			"headnews"=>"".addslashes(htmlspecialchars($_POST['HEADNEWS']))."",
			"headline"=>"".$_POST['HEADLINE']."",
			"detail"=>"".$_POST['DETAIL']."",
			"posted"=>"".$admin_user."",
			"update_date"=>"".$arr['news']['date']."",
			"pic"=>"".$pic."",
			"enable_comment"=>"".$ENABLE_COMMENT."",
			"ran"=>"".$ran."",
                        "linkurl"=>"".$_POST['LINKURL'].""
		)," id_news=".$_GET['id_news']."");
		$db->closedb ();
}

$data ='<?xml version="1.0" encoding="'.$iso.'"?>'."\n";
$data .='<rss version="2.0">'."\n";
$data .='<channel>'."\n";

$data .='<title>'.WEB_TITILE.'</title>'."\n";
$data .='<description>'._ADMIN_NEW_MENU_TITLE.'</description>'."\n";
$data .='<link>'.WEB_URL.'</link>'."\n";
$data .='<lastBuildDate>'.date("D, d M Y H:i:s").'</lastBuildDate>'."\n";

$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
$listof= $db->select_query("SELECT * FROM ".TB_NEWS." where category='2' ORDER BY id_news desc limit 10");

while($result = $db->fetch($listof)) {
$timesdate=ThaiTimeConvert($result['date'],"1","");
	$res['category'] = $db->select_query("SELECT * FROM ".TB_NEWS_CAT." WHERE id='".$result['category']."' ");
	$arr['category'] = $db->fetch($res['category']);

if($result['pic']==1){
$pics=''.WEB_URL.'/icon/news_'.$result['date'].'.jpg';
}else {
$pics=''.WEB_URL.'/images/icon/'.$arr['category']['icon'].'';
}
$data .='<item>'."\n"; 
$data .='<title>'.$result['headnews'].'</title>'."\n"; 
$data .='<link>'.WEB_URL.'/?name=news&amp;file=readnews&amp;id_news='.$result['id_news'].'</link>'."\n"; 
$data .='<pic>'.$pics.'</pic>'."\n";
$data .='<description>'.$result['headline'].'</description>'."\n";
$data .='<pubDate>'.$result['date'].'</pubDate>'."\n";
$data .='</item>'."\n"; 
}

$data .='</channel>'."\n";
$data .='</rss>'."\n";

$f = fopen( 'modules/rss/news.xml' , 'w' ); // 2 อ่านหมายเหตุของบรรทัดนี้ด้านล่าง
fputs( $f , $data );
fclose( $f );

		$ProcessOutput = "<BR><BR>";
		$ProcessOutput .= "<CENTER><A HREF=\"?name=admin&file=main\"><IMG SRC=\"images/icon/login-welcome.gif\" BORDER=\"0\"></A><BR><BR>";
		$ProcessOutput .= "<FONT COLOR=\"#336600\"><B>"._ADMIN_NEW_MESSAGE_EDIT."</B></FONT><BR><BR>";
		$ProcessOutput .= "<A HREF=\"?name=admin&file=news\"><B>"._ADMIN_NEW_MESSAGE_GOBACK."</B></A>";
		$ProcessOutput .= "</CENTER>";
//		$ProcessOutput .= "<meta http-equiv='refresh' content='1; url=?name=admin&file=news'>";
		$ProcessOutput .= "<BR><BR>";
	}else{
		//กรณีไม่ผ่าน
		$ProcessOutput = $PermissionFalse ;
	}
	echo $ProcessOutput ;
}
else if($op == "news_edit"){
	//////////////////////////////////////////// กรณีแก้ไข Form
	if(CheckLevel($admin_user,$op)){
		//ดึงค่า
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$res['news'] = $db->select_query("SELECT * FROM ".TB_NEWS." WHERE id_news='".$_GET['id_news']."' ");
		$arr['news'] = $db->fetch($res['news']);

		$TextContent = $arr['news']['detail'];
		$TextContent = stripslashes($TextContent);
		$HEADLINE = $arr['news']['headline'];
		$HEADLINE= stripslashes($HEADLINE);
		$LINKURL = $arr['news']['linkurl'];
		$LINKURL= stripslashes($LINKURL);                
		$db->closedb ();
?>
<FORM NAME="myform" METHOD=POST ACTION="?name=admin&file=news&op=news_edit&action=edit&id_news=<?=$_GET['id_news'];?>" enctype="multipart/form-data">
<B><?=_ADMIN_FORM_TOPIC;?> :</B><BR>
<INPUT TYPE="text" NAME="HEADNEWS" size="80" value="<?=$arr['news']['headnews'];?>">
<BR><BR>
<B><?=_ADMIN_FORM_CAT;?> :</B><BR>
<SELECT NAME="CATEGORY">
<?
$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
$res['category'] = $db->select_query("SELECT * FROM ".TB_NEWS_CAT." ORDER BY sort ");
while ($arr['category'] = $db->fetch($res['category'])){
	   echo "<option value=\"".$arr['category']['id']."\"";
	   if($arr['category']['id'] == $arr['news']['category']){echo " Selected";}
	   echo ">".$arr['category']['category_name']."</option>";
	   $icons=$arr['category']['icon'];
}
$db->closedb ();
?>
</SELECT>
<BR><BR>
<B><?=_ADMIN_FORM_ICON;?> : </B><BR>
<?
	if ($arr['news']['pic'] !=0){?>
<IMG name="view01" SRC="icon/news_<?=$arr['news']['date'];?>.jpg" <?echo " WIDTH=\""._INEWS_W."\" HEIGHT=\""._INEWS_H."\" ";?> BORDER="0" >
<?} else {?>
<IMG name="view01" SRC="images/news_blank.gif" <?echo " WIDTH=\""._INEWS_W."\" HEIGHT=\""._INEWS_H."\" ";?> BORDER="0" >
<?
	}
?>
<BR>
<input type="file" name="FILE" onpropertychange="view01.src=FILE.value;" style="width:250;"><BR>
<?=_ADMIN_FORM_ICON_WIDTH;?> <?echo _INEWS_W." x "._INEWS_H ;?> <?=_ADMIN_FORM_ICON_WIDTH1;?>
<BR><BR>
<B><?=_ADMIN_FORM_HEADLINE;?> :</B><BR>
<textarea cols="100" rows="10" name="HEADLINE" ><?=$HEADLINE;?></textarea>
<script type="text/javascript">CKEDITOR.replace ( 'editor1',{toolbar: 'AdminBasic'});</script>
<BR><BR>


<B><?=_ADMIN_FORM_DETAIL;?> :</B><BR>
<textarea cols="100" id="DETAIL" rows="50" class="ckeditor"  name="DETAIL" ><?=$TextContent;?></textarea>
<br>
<B><?=_ADMIN_FORM_LINK_URL;?> : </B><BR>
<INPUT TYPE="text" NAME="LINKURL" size="100" value="<?=$LINKURL;?>">
<br>
<B><?=_ADMIN_FORM_FILE_ATT;?> : </B><BR>
<input type="file" name="FILESS" onpropertychange="view01.src=FILESS.value;" style="width:250;">
<br>
<B><?=_ADMIN_NEW_ROTATOR_PIC;?> : </B><BR>
<input type="file" name="FILER" onpropertychange="view01.src=FILER.value;" style="width:250;"><BR>
<?=_ADMIN_FORM_ICON_WIDTH;?> <?echo _IRAN_W." x "._IRAN_H ;?> <?=_ADMIN_FORM_CAT_ICON_WIDTH;?>
<br>
<INPUT TYPE="checkbox" NAME="ENABLE_COMMENT" VALUE="1" <?if($arr['news']['enable_comment']){echo " Checked";};?>> <?=_ADMIN_FORM_ALLOW_COMMENT;?>
<BR>
<input type="submit" value="<?=_ADMIN_NEW_BUTTON_EDIT;?>" name="submit"> <input type="reset" value="<?=_ADMIN_BUTTON_CLEAR;?>" name="reset">
</FORM>
<BR><BR>
<?
	}else{
		//กรณีไม่ผ่าน
		$ProcessOutput = $PermissionFalse ;
	}

}
else if($op == "news_del" AND $action == "multidel"){
	//////////////////////////////////////////// กรณีลบ Multi
	if(CheckLevel($admin_user,$op)){
		while(list($key, $value) = each ($_POST['list'])){
			$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
			$res['news'] = $db->select_query("SELECT * FROM ".TB_NEWS." WHERE id_news='".$value."' ");
			$arr['news'] = $db->fetch($res['news']);

			if ($arr['news']['ran']==1){
			$res['ran'] = $db->select_query("SELECT * FROM ".TB_RANDOM." WHERE rm_news='".$arr['news']['id_news']."' ");
			$arr['ran'] = $db->fetch($res['ran']);
			@unlink("icon/".$arr['ran']['rm_images']."");
			$db->del(TB_RANDOM," rm_news='".$arr['news']['id_news']."' ");
			}

			$db->del(TB_NEWS," id='".$value."' "); 
			$db->closedb ();
			@unlink("icon/news_".$arr['news']['date'].".jpg");


		}
$data ='<?xml version="1.0" encoding="'.$iso.'"?>'."\n";
$data .='<rss version="2.0">'."\n";
$data .='<channel>'."\n";

$data .='<title>'.WEB_TITILE.'</title>'."\n";
$data .='<description>'._ADMIN_NEW_MENU_TITLE.'</description>'."\n";
$data .='<link>'.WEB_URL.'</link>'."\n";
$data .='<lastBuildDate>'.date("D, d M Y H:i:s").'</lastBuildDate>'."\n";

$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
$listof= $db->select_query("SELECT * FROM ".TB_NEWS." where category='2' ORDER BY id_news desc limit 10");

while($result = $db->fetch($listof)) {
$timesdate=ThaiTimeConvert($result['post_date'],"1","");
	$res['category'] = $db->select_query("SELECT * FROM ".TB_NEWS_CAT." WHERE id='".$result['category']."' ");
	$arr['category'] = $db->fetch($res['category']);

if($result['pic']==1){
$pics=''.WEB_URL.'/icon/news_'.$result['date'].'.jpg';
}else {
$pics=''.WEB_URL.'/images/icon/'.$arr['category']['icon'].'';
}
$data .='<item>'."\n"; 
$data .='<title>'.$result['headnews'].'</title>'."\n"; 
$data .='<link>'.WEB_URL.'/?name=news&amp;file=readnews&amp;id_news='.$result['id_news'].'</link>'."\n"; 
$data .='<pic>'.$pics.'</pic>'."\n";
$data .='<description>'.$result['headline'].'</description>'."\n";
$data .='<pubDate>'.$result['date'].'</pubDate>'."\n";
$data .='</item>'."\n"; 
}

$data .='</channel>'."\n";
$data .='</rss>'."\n";

$f = fopen( 'modules/rss/news.xml' , 'w' ); // 2 อ่านหมายเหตุของบรรทัดนี้ด้านล่าง
fputs( $f , $data );
fclose( $f );
		$ProcessOutput = "<BR><BR>";
		$ProcessOutput .= "<CENTER><A HREF=\"?name=admin&file=main\"><IMG SRC=\"images/icon/login-welcome.gif\" BORDER=\"0\"></A><BR><BR>";
		$ProcessOutput .= "<FONT COLOR=\"#336600\"><B>"._ADMIN_NEW_MESSAGE_DEL."</B></FONT><BR><BR>";
		$ProcessOutput .= "<A HREF=\"?name=admin&file=news\"><B>"._ADMIN_NEW_MESSAGE_GOBACK."</B></A>";
		$ProcessOutput .= "</CENTER>";
		$ProcessOutput .= "<BR><BR>";
	}else{
		//กรณีไม่ผ่าน
		$ProcessOutput = $PermissionFalse ;
	}
	echo $ProcessOutput ;
}
else if($op == "news_ran"){
	///////////////////////////////////////////

if($_GET['fix']=='up'){
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$db->update_db(TB_RANDOM,array(
			"status"=>"1"
		)," rm_news=".$_GET['id_news']."");
		$db->closedb ();
}
if($_GET['fix']=='down'){
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$db->update_db(TB_RANDOM,array(
			"status"=>"0"
		)," rm_news=".$_GET['id_news']."");
		$db->closedb ();
}
		$ProcessOutput = "<BR><BR>";
		$ProcessOutput .= "<CENTER><A HREF=\"?name=admin&file=main\"><IMG SRC=\"images/icon/login-welcome.gif\" BORDER=\"0\"></A><BR><BR>";
		$ProcessOutput .= "<FONT COLOR=\"#336600\"><B>"._ADMIN_NEW_MESSAGE_EDIT_RAN."</B></FONT><BR><BR>";
		$ProcessOutput .= "<A HREF=\"?name=admin&file=news\"><B>"._ADMIN_NEW_MESSAGE_GOBACK."</B></A>";
		$ProcessOutput .= "<meta http-equiv='refresh' content='1; url=?name=admin&file=news'>";
		$ProcessOutput .= "</CENTER>";
		$ProcessOutput .= "<BR><BR>";

	echo $ProcessOutput ;
}
else if($op == "news_del"){
	//////////////////////////////////////////// กรณีลบ Form
	if(CheckLevel($admin_user,$op)){
		$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
		$res['new'] = $db->select_query("SELECT * FROM ".TB_NEWS." WHERE id_news='".$_GET['id_news']."' ");
		$arr['new'] = $db->fetch($res['new']);
		if ($arr['new']['ran']==1){
		$res['ran'] = $db->select_query("SELECT * FROM ".TB_RANDOM." WHERE rm_news='".$_GET['id_news']."' ");
		$arr['ran'] = $db->fetch($res['ran']);
		@unlink("icon/".$arr['ran']['rm_images']."");
		$db->del(TB_RANDOM," rm_news='".$_GET['id_news']."' ");
		}
		$db->del(TB_NEWS," id_news='".$_GET['id_news']."' "); 
		$db->closedb ();
		if($_GET['pic'] !='0') {
		@unlink("icon/news_".$_GET['prefix'].".jpg");
		}
$data ='<?xml version="1.0" encoding="'.$iso.'"?>'."\n";
$data .='<rss version="2.0">'."\n";
$data .='<channel>'."\n";

$data .='<title>'.WEB_TITILE.'</title>'."\n";
$data .='<description>'._ADMIN_NEW_MENU_TITLE.'</description>'."\n";
$data .='<link>'.WEB_URL.'</link>'."\n";
$data .='<lastBuildDate>'.date("D, d M Y H:i:s").'</lastBuildDate>'."\n";

$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);
$listof= $db->select_query("SELECT * FROM ".TB_NEWS." where category='2' ORDER BY id_news desc limit 10");

while($result = $db->fetch($listof)) {
$timesdate=ThaiTimeConvert($result['date'],"1","");
	$res['category'] = $db->select_query("SELECT * FROM ".TB_NEWS_CAT." WHERE id='".$result['category']."' ");
	$arr['category'] = $db->fetch($res['category']);

if($result['pic']==1){
$pics=''.WEB_URL.'/icon/news_'.$result['date'].'.jpg';
}else {
$pics=''.WEB_URL.'/images/icon/'.$arr['category']['icon'].'';
}
$data .='<item>'."\n"; 
$data .='<title>'.$result['headnews'].'</title>'."\n"; 
$data .='<link>'.WEB_URL.'/?name=news&amp;file=readnews&amp;id_news='.$result['id_news'].'</link>'."\n"; 
$data .='<pic>'.$pics.'</pic>'."\n";
$data .='<description>'.$result['headline'].'</description>'."\n";
$data .='<pubDate>'.$result['date'].'</pubDate>'."\n";
$data .='</item>'."\n"; 
}

$data .='</channel>'."\n";
$data .='</rss>'."\n";

$f = fopen( 'modules/rss/news.xml' , 'w' ); // 2 อ่านหมายเหตุของบรรทัดนี้ด้านล่าง
fputs( $f , $data );
fclose( $f );
		$ProcessOutput = "<BR><BR>";
		$ProcessOutput .= "<CENTER><A HREF=\"?name=admin&file=main\"><IMG SRC=\"images/icon/login-welcome.gif\" BORDER=\"0\"></A><BR><BR>";
		$ProcessOutput .= "<FONT COLOR=\"#336600\"><B>"._ADMIN_NEW_MESSAGE_DEL."</B></FONT><BR><BR>";
		$ProcessOutput .= "<A HREF=\"?name=admin&file=news\"><B>"._ADMIN_NEW_MESSAGE_GOBACK."</B></A>";
		$ProcessOutput .= "</CENTER>";
		$ProcessOutput .= "<meta http-equiv='refresh' content='1; url=?name=admin&file=news'>";
		$ProcessOutput .= "<BR><BR>";
	}else{
		//กรณีไม่ผ่าน
		$ProcessOutput = $PermissionFalse ;
	}
	echo $ProcessOutput ;
}
?>
						<BR><BR>
					</TD>
				</TR>
			</TABLE>
				</TD>
				</TR>
			</TABLE>
